package com.yang.demo.common;

import lombok.Data;

@Data
public class Result {

    //定义返回值
    private int code;
    private String msg;
    private long total;//记录数量
    private Object data;//数据类型未知所以定义为object

    public  static Result fail(){
        return result(400,"失败",0l,null);
    }
    public  static Result suc(){
        return result(200,"成功",0l,null);
    }
    public  static Result suc(Object data){
        return result(200,"成功",0l,data);
    }
    public  static Result suc(Object data,long total){
        return result(200,"成功",total,data);
    }


    private static Result result(int code,String msg,long total,Object data){
        Result res = new Result();
        res.setData(data);
        res.setCode(code);
        res.setMsg(msg);
        res.setTotal(total);
        return res;
    }
}
